﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void dlBtn_Click(object sender, EventArgs e)
        {
            var user = userTxb.Text.Trim();
            var pwd = pwdTxb.Text.Trim();

            string sql = "select * from Users where Username='" + user + "' and Password='" + pwd + "'";

            var dt = DbHelper.GetData(sql);

            if (dt.Rows.Count > 0)
            {
                this.Label4.Visible = false;

                Session["userName"] = user;
                Session["Id"] = dt.Rows[0].ItemArray[0].ToString();

                Response.Redirect("Default.aspx");

            }
            else
            {
                this.Label4.Text = "用户名或者密码错误";
                this.Label4.Visible = true;
            }
        }
    }
}